package com.ives.launcher.view;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TableRow;
/**
 * 用于实现所有Apps的rootview
 * @author ives
 *
 */
/**
 * 用于实现所有Apps的rootview
 * @author ives
 *
 */
public class View_Apps_Root extends RelativeLayout{
	private View_Apps_Page_Root view_AllApps_Root;//装所有apps页面的容器
	private View_Root view_manager;
	private View_PageIndexBar pageIndexBar;	
	
	public View_Apps_Root(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init();
	}


	public View_Apps_Root(Context context, AttributeSet attrs) {
		this(context, attrs,0);
	}

	public View_Apps_Root(Context context) {
		this(context,null);
	}
	
	public static final int topMenuID = 1;
	public static final int bottomMenuID = 2;
	public static final int centerID = 3;
	public static final int pageIndexBarID = 4;
	
	/**
	 * 初始化
	 */
	private void init(){
		setBackgroundColor(Color.BLACK);
		view_AllApps_Root = new View_Apps_Page_Root(getContext());
		topMenu = new View_Apps_TopMenu(getContext());
		bottomMenu = new View_Apps_BottomMenu(getContext());
		pageIndexBar = new View_PageIndexBar(getContext());
		
		topMenu.setId(topMenuID);
		bottomMenu.setId(bottomMenuID);
		view_AllApps_Root.setId(centerID);
		pageIndexBar.setId(pageIndexBarID);
		
		
		
		RelativeLayout.LayoutParams params1 = new LayoutParams(LayoutParams.FILL_PARENT,70);
		RelativeLayout.LayoutParams params2 = new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT);
		RelativeLayout.LayoutParams params3 = new LayoutParams(LayoutParams.FILL_PARENT,80);
		RelativeLayout.LayoutParams params4 = new LayoutParams(LayoutParams.FILL_PARENT,5);
		
		params1.addRule(RelativeLayout.ALIGN_PARENT_TOP);
		params1.setMargins(10, 0, 10, 10);
		
		params3.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
		
		params4.addRule(RelativeLayout.BELOW,topMenuID);
		
		params2.addRule(RelativeLayout.BELOW,pageIndexBarID);
		params2.addRule(RelativeLayout.ABOVE,bottomMenuID);
		
		
		
		
		this.addView(topMenu,params1);
		this.addView(bottomMenu,params3);
		this.addView(pageIndexBar,params4);
		this.addView(view_AllApps_Root,params2);
		
		bottomMenu.getCenterBtn().setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				view_AllApps_Root.setVisibility(View.VISIBLE);
				setVisibility(View.GONE);
			}
		});

	}
	
	
	
	
	View_Apps_TopMenu topMenu;
	View_Apps_BottomMenu bottomMenu;
	/**
	 * 顶部菜单条
	 * @author ives
	 *
	 */
	public class TopMenu extends TableRow{
		public TopMenu(Context context, AttributeSet attrs) {
			super(context, attrs);
		}
		public TopMenu(Context context) {
			super(context);
		}
	}
	/**
	 * 底部菜单条
	 * @author ives
	 *
	 */
	public class BottomMenu extends TableRow{
		public BottomMenu(Context context, AttributeSet attrs) {
			super(context, attrs);
		}

		public BottomMenu(Context context) {
			super(context);
		}
		
	}
	/**getter and setter**/
	
	public View_Apps_Page_Root getView_AllApps_Root() {
		return view_AllApps_Root;
	}

	public View_Root getView_manager() {
		return view_manager;
	}

	public void setView_manager(View_Root view_manager) {
		this.view_manager = view_manager;
	}


	public View_PageIndexBar getPageIndexBar() {
		return pageIndexBar;
	}


	public void setPageIndexBar(View_PageIndexBar pageIndexBar) {
		this.pageIndexBar = pageIndexBar;
	}
	
	
	
}
